import baseApi from '@/api/api'
import * as types from './mutation-types'

const state = {
	currentUnit: {},
}

const getters = {
	currentUnit: (state) => state.currentUnit, // 查询工件详情
}

const mutations = {
	[types.GET_CURRENT_UNIT](state, payload) {
		// 当前查询工件详情
		state.currentUnit = payload
	},
}

const actions = {
	//查询工件
	getUnitDetail({
		commit
	}, param) {
		return baseApi.getUnitDetail(param).then((res) => {
			commit('GET_CURRENT_UNIT', res.data.data)
			return res.data
		})
	},
	//领取裁片
	receiveSliceCutting({
		commit
	}, param) {
		return baseApi.receiveSliceCutting(param).then((res) => {
			return res.data
		})
	},
	//出库单
	listMaterialInfoAndStore({
		commit
	}, param) {
		return baseApi.listMaterialInfoAndStoreOut(param).then((res) => {
			return res.data
		})
	},

	//获取消息列表
	getMessageReadInfoPage({
		commit
	}, param) {
		return baseApi.getMessageReadInfoPage(param).then((res) => {
			return res.data
		})
	},
	//单个消息已读
	readSingle({
		commit
	}, param) {
		return baseApi.readSingle(param).then((res) => {
			return res.data
		})
	},
	//根据工件码查询同一工单下的工件列表
	getWorkUnitsByUnitNo({
		commit
	}, param) {
		return baseApi.getWorkUnitsByUnitNo(param).then((res) => {
			return res.data
		})
	},

	//邮寄记录
	getMailLogPage({
		commit
	}, param) {
		return baseApi.getMailLogPage(param).then((res) => {
			return res.data
		})
	},
	//查询物流详情
	getFastMailPage({
		commit
	}, param) {
		return baseApi.getFastMailPage(param).then((res) => {
			return res.data
		})
	},
}

export default {
	state,
	getters,
	mutations,
	actions,
}
